<?php

namespace app\admin\model;

use think\Model;
use think\model\concern\SoftDelete;
use think\model\relation\HasOne;

/**
 * Card
 * @controllerUrl 'card'
 */
class Card extends Model
{
    use SoftDelete;
    // 表名
    protected $name = 'card';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    protected $type = [
        'delete_time' => 'timestamp:Y-m-d H:i:s',
    ];


    public function user(): HasOne
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

    public function getUserIdAttr($value, $row)
    {
        return !$value ? '' : $value;
    }
}